package com.midea.iot.course1.javaSE4;


/**
 * 作业1
 * @author xingwuxw
 * 编写一个员工类   (1)属性: 姓名,年龄
 * 如果年龄小于18龄大于150抛出年龄异常
 * 如果姓名为null或者""抛出空异常
 */
public class Staff {
    private String name;  //姓名
    private int age;        //年龄

    public Staff() {
    }

    public Staff(String name, int age) throws Exception{
        if(age<18) {
            throw new Exception("年龄太小了！");
        }else if(age>60) {
            throw new Exception("年龄太大了！");
        }else if(name.isEmpty()) {
            throw new Exception("输入名字不合法！");
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
